package com.lxx.modules.sys.entity;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Range;

import com.lxx.common.BaseEntity;

/**
 *  实体类
 *
 * @author lxx
 */
public class SysPermission extends BaseEntity<Integer>  {
	private static final long serialVersionUID = -2101122368661128736L;

	/** 上级权限ID */
    private Integer pid;

    /** 权限名称 */
    @NotBlank
    @Size(max=30)
    private String name;

    /** 权限类型，0--页面级，1--功能级 */
    @NotNull
    @Range(min=0, max=2)
    private Short type;
    
    private String url;
    
    private Integer order;
    
    private String remark;

    /**
     * 返回 上级权限ID
     *
     * @return 上级权限ID
     */
    public Integer getPid() {
        return pid;
    }

    /**
     * 设置 上级权限ID
     *
     * @param pid 上级权限ID
     */
    public void setPid(Integer pid) {
        this.pid = pid;
    }

    /**
     * 返回 权限名称
     *
     * @return 权限名称
     */
    public String getName() {
        return name;
    }

    /**
     * 设置 权限名称
     *
     * @param name 权限名称
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    /**
     * 返回 权限类型，0--页面级，1--功能级
     *
     * @return 权限类型，0--页面级，1--功能级
     */
    public Short getType() {
        return type;
    }

    /**
     * 设置 权限类型，0--页面级，1--功能级
     *
     * @param type 权限类型，0--页面级，1--功能级
     */
    public void setType(Short type) {
        this.type = type;
    }

    public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", pid=").append(pid);
        sb.append(", name=").append(name);
        sb.append(", type=").append(type);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysPermission other = (SysPermission) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getDelFlag() == null ? other.getDelFlag() == null : this.getDelFlag().equals(other.getDelFlag()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getDelFlag() == null) ? 0 : getDelFlag().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }
}